-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support mobile display #822
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The most important thing is that we should:
- avoid depending on JS for displaying on different devices (always when it's possible), and
- avoid setting direct dimensions of elements (unless it's part of their geometry, or would be much harder otherwise)
This way, we may depend on browser mechanisms, ensuring that the behavior is smooth; mobile devices are worse than desktop, so it's even more important for them.
Besides code review, I've checked how it works in real, and works nicely 👍
@media ${maxDevice.tablet} { | ||
max-width: 75vw; | ||
} | ||
|
||
@media ${maxDevice.mobileL} { | ||
max-width: 60vw; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ItemRow
is a content of grid item, not a grid item itself, therefore it'swidth
should be full grid item- The contents of
ItemRow
arepx
based, and the container is local, so it shouldn't be based onvw
- The contents of
ItemRow
differ, so it shouldn't be generic - You may use
minItemWidth
prop ofEntityGrid
to define minimum size of item if it's needed
const {width} = useWindowSize(); | ||
const isDisplayExecutionTime = width > size.mobileL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be done with CSS - will be more performant, and will always work; the JS here may not necessarily work nicely, especially given that it's pure component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean with display none?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly 🙂
import LabelsFilter from './LabelsFilter'; | ||
import StatusFilter from './StatusFilter'; | ||
import TextSearchFilter from './TextSearchFilter'; | ||
|
||
const EntityListFilters: FC<FilterProps> = props => { | ||
const {isFiltersDisabled, ...rest} = props; | ||
|
||
const isMobile = useIsMobile(); | ||
|
||
const filtersWidth = isMobile ? 'inherit' : '296px'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inherit
is incorrect here, as you don't want to copy the property from parent. Most likely you've meant either initial
or 100%
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I do want it, but ok, I can change it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initial
would make the container use its default behavior, while inherit
would "copy" the same value as the parent container - not the computed one, but the relative one.
As an example, if you'll have HTML (codesandbox):
<style>
div {width: 30%;height: 20px;background: rgba(0, 0, 0, .1);}
.inherit {width: inherit;}
.initial {width: initial;}
</style>
<div><div class="inherit"><div class="inherit"></div></div></div>
<br />
<div><div class="initial"><div class="initial"></div></div></div>
The first container will get smaller and smaller (as it will copy 30%
), and the other one will take the parent's container size (as it will reset to defaults).
Therefore, I believe that you did rather want initial
, but I may be wrong 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, will update it
gap: 16px; | ||
align-items: center; | ||
|
||
${props => (props.isMobile ? `width: 100%;` : '')} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Stretching items for all dimensions will work well instead (it may require adjusting the parent container too, but it may be worth it)
- We should control CSS without JS, using media queries only
position: relative; | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
|
||
width: 296px; | ||
width: ${props => props.$width || '296px'}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the FiltersContainer
code above, we should be able to easily get rid of width
at all here
@@ -44,7 +44,7 @@ const TextSearchFilter: React.FC<FilterProps> = props => { | |||
value={inputValue} | |||
data-cy="search-filter" | |||
disabled={isFiltersDisabled} | |||
style={{width: '296px'}} | |||
style={{width}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may get rid of width
, making it flexible instead
position: fixed; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-between; | ||
|
||
padding-top: 30px; | ||
width: 100px; | ||
width: ${props => props.$width}px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would consider zoom
instead, applied via media queries. I don't think there would be any edge cases, but what do you think?
.ant-layout-sider {
zoom: 0.6;
}
.ant-layout-sider-children > div > div {
zoom: 1.35;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't seen this approach later, this one is not looking perfectly in mobile
04067ca
to
60b88be
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/components/organisms/EntityList/EntityListFilters/StatusFilter/StatusFilter.tsx
Outdated
Show resolved
Hide resolved
src/components/organisms/EntityList/EntityListFilters/TextSearchFilter/TextSearchFilter.tsx
Outdated
Show resolved
Hide resolved
* mobile support for filters, sider and list * entity details and settings optimization * remove unused * some pr fixes * hind adjustment * more mobile improvements * fix tabs * fix navigation for cloud * cloud message fix * fix: log output display / sider * fix: scrolling log output / positioning AI hints promo * simplify scrolling further * fix: full screen log output * fixup stylelint * chore: delete unused parts --------- Co-authored-by: Dawid Rusnak <[email protected]>
This PR...
Changes
Fixes
How to test it
screenshots
Checklist